<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../static/js/jquery-1.8.2.min.js"></script>
    <link rel="stylesheet" href="../static/css/css.css">
</head>
<body>
 [[${pi}]]
 <br>用户名查询<input type="text" name="userName" th:value="${userName}">
 <button id="cx">点击查询</button>
 <input type="button" th:onclick="add()" th:value="添加">
<table>
    <tr>
        <td>用户ID</td>
        <td>用户名</td>
        <td>密码</td>
        <td>真实姓名</td>
        <td>电子邮件</td>
        <td>联系电话</td>
        <td>备注</td>
        <td>冻结状态</td>
        <td>注册日期</td>
        <td>性别</td>
        <td>爱好</td>
        <td>操作</td>
    </tr>
    <tr th:each="li :${pi.list}">
        <td th:text="${li.usersId}"></td>
        <td th:text="${li.userName}"></td>
        <td th:text="${li.password}"></td>
        <td th:text="${li.trueName}"></td>
        <td th:text="${li.email}"></td>
        <td th:text="${li.phone}"></td>
        <td th:text="${li.comments}"></td>
        <td th:text="${li.lockState}"></td>
        <td th:text="${li.registerDate}"></td>
<!--        <td th:text="${li.sex}"></td>-->
        <span>
            <td th:if="${li.sex}==1">女</td>
            <td th:if="${li.sex}==2">男</td>
        </span>
        <td th:text="${li.love}"></td>
        <td>
            <button class="update" th:value="${li.usersId}">点击修改</button>
            <button class="bdelete" th:value="${li.usersId}">点击删除</button>
        </td>
    </tr>
    <tr>
        <td colspan="250px">
            <input type="button" value="首页" th:onclick="page(1)">
            <input type="button" value="上一页" th:onclick="page([[${pi.pageNum}]]==1?[[${pi.pageNum}]]:[[${pi.pageNum - 1}]])">
            <input type="button" value="下一页" th:onclick="page([[${pi.pageNum}]]==[[${pi.pages}]]?[[${pi.pageNum}]]:[[${pi.pageNum+1}]])">
            <input type="button" value="尾页" th:onclick="page([[${pi.pages}]])">
        </td>
    </tr>
</table>
</body>
<script>

    function page(pageNum) {
        console.log(pageNum)
        location.href="/basic/select?pageNum="+pageNum;
    }

    function add() {
        location="/basic/addtz"
    }

    /*
     修改
     */
    $(".update").click(function () {
        let val = $(this).val();
        alert(val)
        location.href="/basic/updateHx?usersId="+val
    })

    /*
     删除
     */
    $(".bdelete").click(function (){
        let val1 = $(this).val();
        alert(val1)
        if (confirm("确定删除?")){
            location.href="/basic/delete?bid="+val1
        }
    });


    $("#cx").click(function () {
        let ery = $("[name=userName]").val();
        location.href="/basic/select?userName="+ery
    })
</script>
</html>